package org.idea.qiyu.live.framework.redis.starter.key;

import org.idea.qiyu.live.framework.redis.starter.key.common.RedisKeyBuilder;
import org.idea.qiyu.live.framework.redis.starter.key.common.RedisKeyLoadMatch;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;

@Configuration
@Conditional(RedisKeyLoadMatch.class)
public class UserProviderCacheKeyBuilder extends RedisKeyBuilder {

    private static final String USER_INFO_KEY = "userInfo";
    private static final String USER_TAG_KEY = "userTag";
    private static final String USER_TAG_LOCK_KEY = "userTagLock";
    private static final String USER_TOKEN_KEY = "userToken";
    private static final String USER_PHONE_KEY = "userPhone";
    private static final String USER_PHONE_LIST_KEY = "userPhoneList";


    public String buildUserInfoKey(Long userId) {
        //qiyu-live-user-provider:userInfo:userId
        return super.getPrefix() + USER_INFO_KEY + super.getSplitItem() + userId;
    }

    public String buildUserTagKey(Long userId) {
        //qiyu-live-user-provider:userTag:userId
        return super.getPrefix() + USER_TAG_KEY + super.getSplitItem() + userId;
    }

    public String buildUserTagLockKey(Long userId) {
        //qiyu-live-user-provider:userTagLock:userId
        return super.getPrefix() + USER_TAG_LOCK_KEY + super.getSplitItem() + userId;
    }

    public String buildUserTokenKey(String token) {
        //qiyu-live-user-provider:userToken:token
        return super.getPrefix() + USER_TOKEN_KEY + super.getSplitItem() + token;
    }

    public String buildUserPhoneKey(String phone) {
        //qiyu-live-user-provider:userPhone:phone
        return super.getPrefix() + USER_PHONE_KEY + super.getSplitItem() + phone;
    }

    public String builderUserPhoneListKey(Long userId) {
        //qiyu-live-user-provider:userPhone:phone
        return super.getPrefix() + USER_PHONE_LIST_KEY + super.getSplitItem() + userId;
    }
}